package com.masterclient.app.modules.aftersale;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.masterclient.app.BaseActivity;
import com.masterclient.app.R;
import com.eoner.baselibrary.utils.ScreenUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 作者：sean
 * 创建时间：2017/8/26 18:35
 * 功能说明：
 */

public class ReturnProgressActivity extends BaseActivity {

    @BindView(R.id.rl_back)
    RelativeLayout rlBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.ll_con)
    LinearLayout llCon;

    List<List<String>> list;
    String state;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_return_progress);
        ButterKnife.bind(this);
        list = (List<List<String>>) getIntent().getSerializableExtra("list");
        state = getIntent().getStringExtra("state");
        initViews();
    }

    @OnClick({R.id.rl_back}) void onClick(View v){
        switch (v.getId()){
            case R.id.rl_back:
                finish();
                break;

        }
    }

    private void initViews() {

        if(list!=null){
            for(int i = 0;i<list.size();i++){
                List<String> progressList = list.get(i);
                View view = View.inflate(mContext,R.layout.item_aftersale,null);
                View v_top = view.findViewById(R.id.v_top);
                View v_bottom = view.findViewById(R.id.v_bottom);
                ImageView iv_tag = (ImageView) view.findViewById(R.id.iv_tag);
                LinearLayout ll_items = (LinearLayout) view.findViewById(R.id.ll_items);

                if(i==0){
                    v_top.setVisibility(View.INVISIBLE);
                    if("1".equals(state)){
                        iv_tag.setImageResource(R.mipmap.img1_shouhou);
                    }else {
                        iv_tag.setImageResource(R.mipmap.img2_shouhou);
                    }
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) iv_tag.getLayoutParams();
                    params.width = ScreenUtils.dp2px(26);
                    params.height = ScreenUtils.dp2px(26);
                    iv_tag.setLayoutParams(params);

                }

                for(int j = 0;j<progressList.size();j++){
                    TextView tv = new TextView(mContext);
                    tv.setText(progressList.get(j));
                    if(j==0){
                        tv.setTextColor(0xff222222);
                        tv.setTextSize(14);
                    }else {
                        tv.setTextColor(0xff666666);
                        tv.setTextSize(12);
                    }

                    if(i==0){
                        if("1".equals(state)){
                            tv.setTextColor(0xd9000000);
                        }else {
                            tv.setTextColor(0xffcc363c);
                        }
                    }else {
                        tv.setTextColor(0xff666666);
                    }

                    ll_items.addView(tv);
                    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tv.getLayoutParams();
                    params.topMargin = ScreenUtils.dp2px(4);
                    tv.setLayoutParams(params);
                }
                llCon.addView(view);
            }
        }
       /* View v = View.inflate(mContext,R.layout.line_divide_h1,null);
        llCon.addView(v);*/
    }


}
